package com.huayun.plugin.flightSimulation.controller;

import com.huayun.plugin.flightSimulation.domain.FlightSimulation;
import com.huayun.plugin.flightSimulation.service.FlightSimulationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/flightSimulation")
public class FlightSimulationController {
    @Autowired
    private FlightSimulationService flightSimulationService;
    @PostMapping("/saveXML")
    public ResponseEntity<String> uploadXML(@RequestParam("assemblyFid") String assemblyFid,
                                    @RequestParam("assemblyFName") String assemblyFName,
                                    @RequestParam("xmlFid") String xmlFid,
                                    @RequestParam("xmlFile") MultipartFile xmlFile) {
        String res = flightSimulationService.saveXML(assemblyFid,assemblyFName,xmlFid,xmlFile);
        return ResponseEntity.ok(res);
    }
    @PostMapping("/searchSavedXMLAssemInfo")
    public ResponseEntity<FlightSimulation> uploadXML(@RequestParam("assemblyFid") String assemblyFid) {
        FlightSimulation res = flightSimulationService.searchSavedXMLAssemInfo(assemblyFid);
        return ResponseEntity.ok(res);
    }
}
